﻿@using System.Configuration
@{
    ViewBag.Title = "Quản Lý Thể Loại";
    Layout = "~/Views/Shared/_Admin_Layout.cshtml";
}
@section CssImport
{
    <style>
        .child-opener-image
        {
            cursor: pointer;
        }
        .child-opener-image-column
        {
            text-align: center;
        }
        .jtable-dialog-form
        {
            min-width: 220px;
        }
        .jtable-dialog-form input[type="text"]
        {
            min-width: 200px;
        }
    </style>
}
<div id="div-main-menu" class="left-side-bar">
    @Html.Partial("_AdminMenu")
</div>
<div id="div-main-content" class="right-side-bar">
    <h2>QUẢN LÝ THỂ LOẠI</h2>
    <div id="LibraryCategoryContainer"></div>
    <script type="text/javascript">

        $(document).ready(function () {
            $('#LibraryCategoryContainer').jtable({
                title: 'Categories List',
                paging: true, //Enable paging
                pageSize: @ConfigurationManager.AppSettings["PageSize"],
                sorting: true, //Enable sorting
                defaultSorting: 'Name ASC',
                //openChildAsAccordion: true, //Enable this line to show child tabes as accordion style
                actions: {
                    listAction: '@Url.Action("GetCategoryList", "Category")',
                    updateAction: '@Url.Action("UpdateCategory", "Category")',
                    createAction: '@Url.Action("AddCategory", "Category")'
                },
                fields: {
                    ID: {
                        key: true,
                        create: false,
                        edit: false,
                        list: false
                    },
                    CategoryName: {
                        title: 'Tên thể loại'
                    },
                    Description: {
                        title: 'Mô tả',
                        type: 'textarea'
                    },
                 },
                //validate cac field trong bang Book_Category
                formCreated: function (event, data) {
                    data.form.find('input[name="CategoryName"]').addClass('validate[required]');
                    data.form.find('input[name="Description"]').addClass('validate[required]');
                    data.form.validationEngine();
                },
                formSubmitting: function (event, data) {
                    return data.form.validationEngine('validate');
                },
                formClosed: function (event, data) {
                    data.form.validationEngine('hide');
                    data.form.validationEngine('detach');
                },
            });

            //Load Category list from server
        
                $('#LibraryCategoryContainer').jtable('load');
            });  
    </script>
</div>
<div style="clear: both"></div>
